package net.xumf.support.enums;

import lombok.Getter;
import net.xumf.support.exception.NotFoundEnumInfoException;

import java.util.Arrays;

@Getter
public enum  UserStatusEnum {

    NORMAL(10, "正常"),
    LOCK(11, "锁定"),
    ;

    private int code;
    private String msg;

    UserStatusEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static UserStatusEnum getByCode(int code) {
        return Arrays.stream(values()).filter(o -> o.code == code).findAny()
                .orElseThrow(() -> new NotFoundEnumInfoException(CodeEnum.ENUM_NOT_FOUND_ERROR));
    }
}
